﻿using System;
using System.Collections.Generic;
using System.Text;
using com.calitha.goldparser;
namespace com.calitha.goldparser.sql
{
    public class IdMember
    {
        public TerminalToken Id { get; set; }
    }
    public class IdList : Queue<IdMember> { }
    public class Tuple // represent <Tuple> sybmol
    {
        public Statements StatementTuple = new Statements();
        public ExpressionList ExpresionListTuple = new ExpressionList();
        public void AddTuple(Tuple newTuple)
        {
            this.StatementTuple.AddStatements(newTuple.StatementTuple);
            this.ExpresionListTuple.AddExpressionList(newTuple.ExpresionListTuple);
        }
    }
    public class PredExp //<represent <Pred Exp> Symbol
    {
        public List<TerminalToken> ListIDs = new List<TerminalToken>();
        public List<TerminalToken> ListIntegers = new List<TerminalToken>();
        public List<TerminalToken> ListReals = new List<TerminalToken>();
        public List<TerminalToken> ListStrings = new List<TerminalToken>();
        public Tuple Tuple = new Tuple();
        public void AddExpresion(PredExp ex)
        {
            this.ListIDs.AddRange(ex.ListIDs);
            this.ListIntegers.AddRange(ex.ListIntegers);
            this.ListReals.AddRange(ex.ListReals);
            this.ListStrings.AddRange(ex.ListStrings);
            this.Tuple.AddTuple(ex.Tuple);
        }
    }
    public class Expression : Queue<PredExp> //represent <Expresion> Symbol
    {
        public void AddExpression(Expression exp)
        {
            foreach (PredExp predExp in exp)
            {
                this.Enqueue(predExp);
            }
        }
    }
    public class ExpressionList : Queue<Expression> //represent <Expr List> symbol
    {
        public void AddExpressionList(ExpressionList newList)
        {
            foreach (Expression exp in newList)
            {
                this.Enqueue(exp);
            }
        }
    }
    public class InsertStm
    {
        public IdList IdList;
        public ExpressionList ExprList;
    }
    public class SelectStm
    {
        public Expression WhereExpresion;
        public Expression HavingExpresion;
    }
    public class UpdateStm
    {
        public Expression WhereExpresion;
        public AssignList AssignList;
    }
    public class AssignList : List<Assign>
    {

    }
    public class Assign
    {
        public TerminalToken Id;
        public Expression Expression;
    }
    public class DeleteStm
    {
        public Expression Expression;
    }
    public class Statements
    {
        public List<InsertStm> ListInserts = new List<InsertStm>();
        public List<SelectStm> ListSelect = new List<SelectStm>();
        public List<UpdateStm> ListUpdate = new List<UpdateStm>();
        public List<DeleteStm> ListDelete = new List<DeleteStm>();
        public void AddStatements(Statements statements)
        {
            this.ListInserts.AddRange(statements.ListInserts);
            this.ListSelect.AddRange(statements.ListSelect);
            this.ListUpdate.AddRange(statements.ListUpdate);
            this.ListDelete.AddRange(statements.ListDelete);
        }
        
    }

}
